<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

class CreateRechargeCommissionTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('recharge_commission', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('from_uid') ->comment('代充值人的uid')->default(0);
            $table->integer('to_uid')   ->comment('需要充值人的uid')->default(0);
            $table->string('order_sn') ->comment('充值订单号')->default(0);
            $table->integer('total_amount') ->comment('充值金额')->default(0);
            $table->integer('commission_rate') ->comment('佣金比例')->default(0);
            $table->decimal('commission') ->comment('佣金金额')->default(0);
            $table->decimal('commission_Lv1') ->comment('一级佣金金额')->default(0);
            $table->decimal('commission_Lv2') ->comment('二级佣金金额')->default(0);
            $table->decimal('commission_Lv3') ->comment('三级佣金金额')->default(0);
            $table->decimal('commission_Lv4') ->comment('四级佣金金额')->default(0);
            $table->tinyInteger('pay_status') ->comment('充值状态 0 未支付 1 充值中 2 充值成功')->default(0);
            $table->tinyInteger('direction') ->comment('佣金去向：0 合伙人佣金 1 分销佣金')->default(0);
            $table->tinyInteger('pay_channel') ->comment('支付类型： 1 微信 2 支付宝')->default(0);
            $table->timestamp('created_at')  ->comment('创建时间')->default(DB::raw('CURRENT_TIMESTAMP'));
            $table->timestamp('updated_at')  ->comment('修改时间')->default(DB::raw('CURRENT_TIMESTAMP'));

        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('recharge_commission');
    }
}
